<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    response.setHeader("cache-control","public");
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/common.css">
    <link type="text/css" rel="stylesheet" href="<%=path%>/static/css/examMng/core.css"/>
    <link rel="stylesheet" href="<%=path%>/static/css/practice/text.css"/>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/paperMng.css">
    <!--bootstrap基础引用 start-->
	<script type="text/javascript" src="<%=path%>/static/jstreeview/bootstrap/jquery-3.1.1.min.js"></script>
	<script type="text/javascript" src="<%=path%>/static/js/bootstrap.min.js"></script>
	<!--bootstrap基础引用 end-->
	<!--bootstrap-dialog start-->
	<link rel="stylesheet" type="text/css" href="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.css">
	<script type="text/javascript" src="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/loading/css/style.css" />
    <style type="text/css">
        .popWindow {
            background-color:#9D9D9D;
            width: 100%;
            height: 100%;
            left: 0;
            top: 0;
            filter: alpha(opacity=50);
            opacity: 0.5;
            z-index: 1;
            position: absolute;
        }
        .maskLayer {
            background-color:#000;
            width: 200px;
            height: 30px;
            line-height: 30px;
            left: 50%;
            top: 50%;
            color:#fff;
            z-index: 2;
            position: absolute;
            text-align:center;
        }
    </style>
    <script src="<%=path%>/static/loading/js/prefixfree.min.js"></script>
    <script src="<%=path%>/static/loading/js/modernizr.js"></script>
    <!--bootstrap-dialog end-->
    <script src="<%=path%>/static/js/respond.js"></script>
    <!--[if !IE]> -->
    <script type="text/javascript">
        window.jQuery || document.write("<script src='<%=path%>/static/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
    </script>
    <!-- <![endif]-->

    <script type="text/javascript">
        window.jQuery || document.write("<script src='<%=path%>/static/js/jquery-1.9.1.min.js'>" + "<" + "/script>");
    </script>
</head>
<body>
<jsp:include page="../head.jsp" flush="true"/>
<!--body begin-->
<div onclick="showDiv()" style="display:block; cursor:pointer">
</div>
<div id="popWindow" class="popWindow" style="display: none;">
</div>
<div class="main-container">
    <div class="container info-add body-box">
        <div class="additem-main">
            <div class="title-top" style="background: #4c4ca6">
                <p>试题维护:</p>
                <a href="javascript:history.go(-1);" class="retun" style="color: #FFFFFF; text-decoration:none"><i class="glyphicon glyphicon-arrow-left"></i>返回</a>
            </div>
            <div style="height:34px;margin-top: 20px;padding-left: 48px;">
                <a class="btn btn-success" data-toggle="modal" data-target="#myModal" style="background: #4c4ca6">导入试题</a>
            </div>

            <div id="sttypechoose" class="additem-content row" style="margin-top:15px ;">
                <c:forEach items="${typeList }" var="type">
                    <div class="firstbox">
                        <div class="col-lg-2 col-md-2 col-sm-3 col-xs-5 additem-content-title">${type.typeName }</div>
                        <div class="col-lg-7 col-md-8 col-sm-6 col-xs-3 dottedline"></div>
                        <div class="col-lg-1 col-md-2 col-sm-3 col-xs-4 additem-content-num">${type.typeCount }</div>
                        <a href="javascript:doPost('<%=basePath %>depository/toAddQuestion','${type.typeId}','${conId }')"
                           class="btn btn-info" style="background: #4c4ca6;color: #FFFFFF">新增</a>
                    </div>
                </c:forEach>
            </div>
            <div class="loader" style="z-index: 999">
                <div class="dot"></div>
                <div class="dot"></div>
                <div class="dot"></div>
                <div class="dot"></div>
                <div class="dot"></div>
            </div>
        </div>
    </div>
</div>
<!-- 提交弹出框 -->
<!-- 答题面板 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog mtk-box" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title text-tip" id="myModalLabel">试题导入：</h4>
            </div>
            <form id="importForm" enctype="multipart/form-data" class="am-form">
                <div class="modal-body bigbox">
						<span class="">
							<input id="myFile" type="file" value="" accept=".xls" name="myFile"/>
						</span>
                </div>
            </form>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <a type="button" class="btn btn-info" href="#" onclick="importExcel();" style="color: #FFFFFF; background: #4c4ca6"><i
                        class="glyphicon glyphicon-submit" style="color: #FFFFFF"></i>确认</a>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        // $('#topMain').children().eq(4).addClass('active'); // 追加样式;

        //试卷管理
        if (${role eq 'master'}) {
            $('#topMain').children().eq(0).addClass('active'); // 追加样式;
            $('#topMain').children().eq(0).children().attr('href', '#');
        } else if (${role eq 'trainee'}) {
            $('#topMain').children().eq(0).addClass('active'); // 追加样式;
            $('#topMain').children().eq(0).children().attr('href', '#');
        } else {
            $('#topMain').children().eq(3).addClass('active'); // 追加样式;
            // $('#topMain').children().eq(3).children().attr('href', '#');
        }
        $('.loader').hide();
    })
    //选中的效果
    $(document).ready(function () {
        $("#sttypechoose a .firstbox").mousedown(function () {
            $(this).css("background-color", "rgb(238, 250, 255)");
        });
        $("#sttypechoose a .firstbox").mouseup(function () {
            $(this).css("background-color", "rgb(255, 255, 255)");
        });
    });
    var nums = 0;
    $(document).ready(function () {
        nums = $(".main-container .info-add").length;
        footer_position();
        //当浏览器窗口大小改变时，设置显示内容的高度
        $(window).resize(function () {
            footer_position();
        });
    });

    function importExcel() {
        $('.loader').show();
        $('#myModal').modal('hide');
        showDiv();
        var formElement = $("#importForm")[0];
        var formData = new FormData(formElement);
        setTimeout(function(){
            $.ajax({
                type: "POST",
                url: "<%=basePath%>depository/importQuestions?conId=${conId}",
                data: formData,
                async: true,
                cache: false,
                contentType: false,
                processData: false,
                success: function (data) {
                    $('.loader').hide();
                    BootstrapDialog.confirm({
                        title : '提示',
                        message : data.msg,
                        size : BootstrapDialog.SIZE_SMALL,
                        type : BootstrapDialog.TYPE_DEFAULT,
                        closable : true,
                        btnCancelLabel : '取消',
                        btnOKLabel : '确定',
                        callback:function(result){
                            location.reload();
                        }
                    });
                }
            })
        }, 1000);
    }
    function test() {
        var formData = new FormData(formElement);

    }
    function footer_position() {
        var winHeight = $(window).height();
        var myHeight = winHeight - 65 - 82 - 50;
        //alert(myHeight+"-"+$(".main").height());
        if ($(".main-container").height() <= myHeight) {
            $(".kw-footer").css("position", "fixed");
            $(".kw-footer").css("bottom", "0");
            $(".main-container").css("min-height", myHeight + "px");
        } else {
            $(".kw-footer").css("position", "initial");
        }
    }

    function doPost(to, p, l) {  // to:提交动作（action）,p,l:参数
        var myForm = document.createElement("form");
        myForm.method = "post";
        myForm.action = to;
        var myInput = document.createElement("input");
        var myInput2 = document.createElement("input");
        myInput.setAttribute("name", "typeId");  // 为input对象设置name
        myInput.setAttribute("value", p);  // 为input对象设置value
        myInput2.setAttribute("name", "conId");  // 为input对象设置name
        myInput2.setAttribute("value", l);  // 为input对象设置value
        myForm.appendChild(myInput);
        myForm.appendChild(myInput2);
        document.body.appendChild(myForm);
        myForm.submit();
        document.body.removeChild(myForm);  // 提交后移除创建的form
    }

    function showDiv() {
        document.getElementById('popWindow').style.display = 'block';
    }
    function closeDiv() {
        document.getElementById('popWindow').style.display = 'none';
    }

    //打开模态窗口
    $('#dtmb').modal({backdrop: 'static', keyboard: false, show: false});
    $('#myModal').modal({backdrop: 'static', keyboard: false, show: false});
</script>
<!--body end-->

</body>
</html>
